﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;

using System.Web.Script.Services;
namespace JTicket.UI.Service
{
    /// <summary>
    /// Summary description for JT_TitleSvc
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    [GenerateScriptType(typeof(JTicket.Model.D_TitleInfo))]
    [GenerateScriptType(typeof(JTicket.Model.C_CodeNote))]
    [GenerateScriptType(typeof(JTicket.Model.D_Boardinfo))]
    [System.Web.Script.Services.ScriptService]
    public class JT_TitleSvc : System.Web.Services.WebService
    {
        [WebMethod] 
        public List<Model.D_Boardinfo> getTop6Boarinfo()
        {
            BLL.D_Boardinfo bllBoard = new BLL.D_Boardinfo();
            return bllBoard.GetList(6);
        } 
        [WebMethod]

        public List<Model.D_TitleInfo> getTop20TitleInfo()
        {
            BLL.D_OperInfo bllOper = new BLL.D_OperInfo();
            BLL.C_TheaterInfo bllTheaterInfo = new BLL.C_TheaterInfo();
            BLL.D_TitleInfo bllTitle = new BLL.D_TitleInfo();

            return bllTitle.GetList(20,
                bllOper.Oper().ThCode,
                bllTheaterInfo.GetModel(bllOper.Oper().ThCode).GroupRole);
        } 
        [WebMethod]
        public string Add(JTicket.Model.D_TitleInfo Model)
        {
            string sTitleCode = Model.StitleCode;
            string sThCode = Model.ThCode;
            string sThreater = Model.Stheater;
            if (!BLL.D_TitleInfo.Exists(sTitleCode))
            {
                if (BLL.D_TitleInfo.IsCount(sThCode))
                {
                    BLL.D_TitleInfo.Add(Model);
                    BLL.D_SubAreaProc.AddProc(Model.StitleCode, Model.ThCode);
                    return "添加成功！";
                }
                else
                    return Model.Stheater + " 未生成座位图片！";
            }
            else
                return "该剧目编号已存在!";

        }
        [WebMethod]
        public List<JTicket.Model.C_CodeNote> GetTitleType()
        {
            return BLL.C_CodeNote.GetListAllByGroupCod("TitleSort");
        }

        [WebMethod]
        public void Delete(string TitleCode)
        {
            BLL.D_TitleInfo.Delete(TitleCode);

        }
        [WebMethod]
        public void Deletes(string TitleCode)
        {
            string[] titleCode = TitleCode.TrimEnd('|').Split('|');
            foreach (var code in titleCode)
            {
                BLL.D_TitleInfo.Delete(code);
            }
        }
        [WebMethod]
        public Model.D_TitleInfo GetModel(string TitleCode)
        {
            BLL.D_TitleInfo bllTitle = new BLL.D_TitleInfo();
            return bllTitle.GetModel(TitleCode);
        }

        [WebMethod]
        public string Update(JTicket.Model.D_TitleInfo Model)
        {
            if (BLL.D_TitleInfo.Exists(Model.StitleCode))
            {
                BLL.D_TitleInfo.Update(Model);
                return "修改成功！";
            }
            else
                return "该剧目不存在!";
        }

    }
}
